package com.im.file.component;

import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.springframework.stereotype.Component;

import com.im.file.task.UploadTask;

/**
 * 描述：
 * 
 * @author XiaHui
 * @date 2015年12月30日 下午8:52:38
 * @version 0.0.1
 */
@Component
public class UploadComponent {

	private ConcurrentLinkedQueue<UploadTask> queue = new ConcurrentLinkedQueue<UploadTask>();
	private ExecutorService pool = Executors.newFixedThreadPool(3);

	public UploadComponent() {
		initMessageHandler();
	}

	private void initMessageHandler() {
		for (int i = 0; i < 3; i++) {
			pool.execute(new UploadHandlerThread(queue));
		}
	}

	public void push(UploadTask task) {
		queue.add(task);
	}
}
